package com.swsc.solarverse.service;

import com.swsc.solarverse.common.model.PageInfo;
import com.swsc.solarverse.common.mybatis.MybatisService;
import com.swsc.solarverse.dao.entity.DefectDO;
import com.swsc.solarverse.model.*;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author AutoGenerator
 * @since 2022-06-28
 */
public interface IDefectService extends MybatisService<DefectDO> {
    DefectDO getAndCheck(Integer organNo, Integer id);
    /**
     * 故障编号
     * @param defectNo
     * @return
     */
    DefectDO getByDefectNo(Long defectNo);
    /**
     * 统计电站损耗
     * @param queryBo
     * @return
     */
    List<CorporationDefectLossBO> statisticsCorporationDefectLoss(DefectQueryBO queryBo);

    /**
     * 缺陷数量统计
     * @param queryBo
     * @return
     */
    DefectSumBO defectSum(DefectQueryBO queryBo);

    /**
     * 最新巡检时间
     * @param organNo
     * @return
     */
    LocalDateTime maxPatrolTime(Integer organNo);
    LocalDateTime maxCategoryPatrolTime(Integer organNo, String faultCategory);

    /**
     * 重复出现次数
     * @return
     */
    List<DefectRepeatSumBO> statisticsRepeatDefect(DefectQueryBO queryBo);

    /**
     * 平均消缺时间
     * @param queryBo
     * @return
     */
    Integer avgDealTime(DefectQueryBO queryBo);

    /**
     * 各型号故障统计
     * @param organNoIn
     * @return
     */
    List<DefectSumBO> chartDefectSumModel(List<Integer> organNoIn);

    /**
     * 巡检统计
     * @param organNoIn
     * @return
     */
    List<DefectSumBO> chartPatrolSum(List<Integer> organNoIn);


    /**
     * 消缺处理统计(天)
     * @param organNoIn
     * @param start
     * @param end
     * @return
     */
    List<DefectSumBO> chartDefectSumDay(List<Integer> organNoIn, Date start, Date end);

    /**
     * 消缺处理统计(月)
     * @param organNoIn
     * @param start
     * @param end
     * @return
     */
    List<DefectSumBO> chartDefectSumMonth(List<Integer> organNoIn, Date start, Date end);

    /**
     * 消缺处理统计(年)
     * @param organNoIn
     * @param start
     * @param end
     * @return
     */
    List<DefectSumBO> chartDefectSumYear(List<Integer> organNoIn, Date start, Date end);

    /**
     * 缺陷类型统计
     * @param organNoIn
     * @return
     */
    List<ChartDefectTypeSumBO> chartDefectTypeSum(List<Integer> organNoIn, LocalDateTime startTime, LocalDateTime endTime, Collection<String> faultCategoryIn);

    /**
     * 故障预警
     * @param organNoIn
     * @return
     */
    List<DefectWarnStatisticsBO> defectWarn(List<Integer> organNoIn, LocalDateTime startTime, LocalDateTime endTime, Collection<String> faultCategoryIn);

    /**
     * 保存或更新
     * @param defectDo
     */
    void saveOrUpdateDefect(DefectDO defectDo);

    /**
     * 巡检时间
     * @param organNo
     * @return
     */
    List<PatrolTimeBO> listPatrolTime(Integer organNo, String faultCategory);

    /**
     * 区域
     * @param organNo
     * @return
     */
    List<StationZoneBO> listZones(Integer organNo);


    /**
     * 无人机巡检次数统计
     * @param organNoIn
     * @return
     */
    List<UavFlyRecordCountBO> uavPatrolSum(List<Integer> organNoIn);

    /**
     * 获取故障类型
     * @param organNo
     * @param start
     * @param end
     * @return
     */
    List<String> getDefectTypes(Integer organNo, LocalDateTime start, LocalDateTime end, String faultCategory);

    /**
     * 故障设备统计
     * @param queryBo
     * @return
     */
    List<ChartDefectTypeSumBO> chartDefectTypeDeviceSum(DefectQueryBO queryBo);


    /**
     * 查询电站故障详情（list)
     * @param queryBo
     * @return
     */
    List<DefectDO> listStationDefectBO(DefectQueryBO queryBo );

    /**
     * 查询电站故障详情（page)
     * @param queryBo
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageInfo<DefectDO> page(DefectQueryBO queryBo,Integer pageNo, Integer pageSize);


    /**
     * 按总，年，月，周统计缺陷
     * @param organNo
     * @return
     */
    DefectStatisticsBO defectStatistics(Integer organNo);

    /**
     * 总缺陷统计
     * @param organNo
     * @param startDate
     * @param endDate
     * @return
     */
    DefectStatisticsBO defectStatistics(Integer organNo, String startDate, String endDate);

    /**
     * 分页统计缺陷数量
     * @param organNo
     * @param repeatTimes
     * @param pageNo
     * @param pageSize
     * @return
     */
    PageInfo<DefectStatisticsBO> pageStatisticsDefectCount(Integer organNo, Integer repeatTimes, Integer pageNo, Integer pageSize);

    List<Map<String, Object>> statisticsDefectModel(Integer organNo);
}
